﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using HengTong.Model.Db;
using HengTong.Model.Db.Hr;


namespace HengTong.ViewModel.Person.SysPersonMedicalBatcheVms
{
    public partial class SysPersonMedicalBatcheListVm : BasePagedListVM<SysPersonMedicalBatcheView, SysPersonMedicalBatcheSearcher>
    {

        protected override IEnumerable<IGridColumn<SysPersonMedicalBatcheView>> InitGridHeader()
        {
            return new List<GridColumn<SysPersonMedicalBatcheView>>{
                this.MakeGridHeader(x => x.BatchName),
                this.MakeGridHeader(x => x.MedicalType),
                this.MakeGridHeader(x => x.Hospital),
                this.MakeGridHeader(x => x.MedicalDate),
                this.MakeGridHeader(x => x.Remark),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysPersonMedicalBatcheView> GetSearchQuery()
        {
            var query = DC.Set<SysPersonMedicalBatche>()
                .CheckContain(Searcher.BatchName, x=>x.BatchName)
                .CheckContain(Searcher.MedicalType, x=>x.MedicalType)
                .CheckContain(Searcher.Hospital, x=>x.Hospital)
                .CheckBetween(Searcher.MedicalDate?.GetStartTime(), Searcher.MedicalDate?.GetEndTime(), x => x.MedicalDate, includeMax: false)
                .Select(x => new SysPersonMedicalBatcheView
                {
				    ID = x.ID,
                    BatchName = x.BatchName,
                    MedicalType = x.MedicalType,
                    Hospital = x.Hospital,
                    MedicalDate = x.MedicalDate,
                    Remark = x.Remark,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysPersonMedicalBatcheView : SysPersonMedicalBatche{

    }
}
